<?php
declare (strict_types = 1);

namespace app\api\controller;

use think\facade\View;
use think\facade\Db;
use think\captcha\facade\Captcha;

use app\common\model\Region as RegionModel;
/**
 * @title 省市区管理
 * @description 省市区管理
 */
class Region extends Base
{
    private $user=[];

    function __construct(){
        parent::__construct();
    }

    /**
     * @title 获取省市区列表
     * @description 省：parent_id=0，level=1，市：parent_id=相应的省id，level=2，区：parent_id=相应的市id，level=3
     * @author 开发者 唐寅
     * @url /api/Region/getRegionList
     * @method GET POST
     *
     //* @param name:token type:varchar require:1 default:0 other: desc:token
     * @param name:parent_id type:varchar require:1 default:0 other: desc:parent_id=0为省
     * @param name:level type:varchar require:1 default:0 other: desc:1=省，2=市，3=区
     */
    public function getRegionList(){
        $param = input('param.');
        $RegionModel = new RegionModel();
        $parent_id = isset($param['parent_id'])?$param['parent_id']:0;
        $level = isset($param['level'])?$param['level']:1;
        $res = $RegionModel
            ->where("parent_id","=",$parent_id)
            ->where("level",'=',$level)
            ->select();
        return dyajaxReturn(1,'获取成功',$res);
    }

}
